<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回一个文件的信息</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.finfo-file" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">finfo_file</h1>
  <h1 class="refname">finfo::file</h1>
  <p class="verinfo">(PHP &gt;= 5.3.0, PECL fileinfo &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">finfo_file</span> -- <span class="refname">finfo::file</span> &mdash; <span class="dc-title">返回一个文件的信息</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.finfo-file-description">
  <h3 class="title">说明</h3>
  <p class="para">过程化风格</p>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><a href="finfo.file.html" class="methodname">finfo_file</a></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$finfo</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$file_name</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = FILEINFO_NONE</span></span>
   [, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$context</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ]] ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="finfo.file.html" class="methodname">finfo::file</a></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$file_name</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$options</code><span class="initializer"> = FILEINFO_NONE</span></span>
   [, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$context</code><span class="initializer"> = <strong><code>NULL</code></strong></span></span>
  ]] ) : <span class="type">string</span></div>


  <p class="para rdfs-comment">
   本函数用来获取一个文件的信息。
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-function.finfo-file-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">finfo</code></dt>

     <dd>

      <p class="para">
       <span class="function"><a href="finfo_open.html" class="function">finfo_open()</a></span> 函数所返回的 fileinfo 资源。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">file_name</code></dt>

     <dd>

      <p class="para">
       要检查的文件名。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <p class="para">
       一个 <a href="fileinfo.constants.html" class="link">Fileinfo
       常量 </a> 或多个 <a href="fileinfo.constants.html" class="link">Fileinfo 常量 </a> 进行逻辑或运算。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">context</code></dt>

     <dd>

      <p class="para">
       关于 <em>contexts</em> 的更多描述，请参考 <a href="ref.stream.html" class="xref">Stream 函数</a>。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.finfo-file-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回 <code class="parameter">file_name</code> 参数指定的文件信息。
   发生错误时返回 <strong><code>FALSE</code></strong> 。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.finfo-file-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2757">
    <p><strong>Example #1 <span class="function"><a href="finfo.file.html" class="function">finfo_file()</a></span> 例程</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$finfo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">finfo_open</span><span style="color: #007700">(</span><span style="color: #0000BB">FILEINFO_MIME_TYPE</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;返回&nbsp;mime&nbsp;类型<br /></span><span style="color: #007700">foreach&nbsp;(</span><span style="color: #0000BB">glob</span><span style="color: #007700">(</span><span style="color: #DD0000">"*"</span><span style="color: #007700">)&nbsp;as&nbsp;</span><span style="color: #0000BB">$filename</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">finfo_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$finfo</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$filename</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">finfo_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$finfo</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
text/html
image/gif
application/vnd.ms-excel
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.finfo-file-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="finfo.buffer.html" class="function" rel="rdfs-seeAlso">finfo_buffer()</a> - 别名 finfo_buffer()</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>